<template>
    <component is="a-modal" v-model:visible="visible" width="50%" :title="title" :mask-closable="false"
        :ok-loading="loading" @cancel="close" @before-ok="submit">
        <div>
            <a-form ref="formRef" :model="formData" :rules="rules" :auto-label-width="true">
                <a-form-item label="UID" field="uid">
                    <a-input v-model="formData.uid" placeholder="请输入" @blur="getSearch" />
                </a-form-item>
                <a-form-item label="新手机号" field="mobile">
                    <a-input v-model="formData.mobile" placeholder="请输入" />
                </a-form-item>
                <div>
                    <a-descriptions title="用户信息" bordered :column="5">
                        <a-descriptions-item label="ID:" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="会员账号" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="昵称" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="注册手机号" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="邮箱" :span="1">{{  }}</a-descriptions-item>
                    </a-descriptions>
                    <a-descriptions title="用户实名信息" bordered :column="4">
                        <a-descriptions-item label="ID:" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="实名类型" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="实名手机号" :span="1">{{  }}</a-descriptions-item>
                        <a-descriptions-item label="实名状态" :span="1">{{  }}</a-descriptions-item>
                    </a-descriptions>

                </div>
                <a-form-item label="操作密码" field="admin_pay_password">
                    <a-input-password v-model="formData.admin_pay_password" placeholder="请输入" />
                </a-form-item>
                <a-form-item label="谷歌验证码" field="google_code">
                    <a-input v-model="formData.google_code" placeholder="请输入" />
                </a-form-item>
            </a-form>
        </div>
    </component>
</template>
<script setup>
import { onMounted, ref, reactive, computed, watch } from 'vue'
import funApi from '@/api/message/tool'
import { Message } from '@arco-design/web-vue'
import { throttle } from 'lodash';
import tool from '@/utils/tool'
const emit = defineEmits(["success"]);
const formRef = ref()
const visible = ref(false);
const title = ref('')
const loading = ref(false);
const formData = reactive({
    uid: '',
    mobile: '',
    admin_pay_password: '',
    google_code: '',
})
const rules = ref({
    uid: [{ required: true, message: '请输入' }],
    mobile: [{ required: true, message: '请输入' }],
    admin_pay_password: [{ required: true, message: '请输入' }],
    google_code: [{ required: true, message: '请输入' }],
});
const open = async (data) => {
    visible.value = true;
    formRef.value.resetFields()
    title.value = '修改实名认证手机号'
    getParams()
}
const submit = async (done) => {
    const validate = await formRef.value?.validate()
    if (!validate) {
        loading.value = true
        try {
            let data = { ...formData }
            let result = await funApi.tool_update_paystate(data)
            if (result.code === 200) {
                Message.success('操作成功')
                emit('success')
                done(true)
            }
            setTimeout(() => {
                loading.value = false
            }, 500)
        } catch {
            loading.value = false
        }
    }
    done(false)

}
const userData=ref({})
const getSearch = async () => {
    const { data } = await funApi.tool_edit_phone_config({ type: 'userAndAuth', uid: formData.uid })
    userData.value=data.data
}
const paramsData = ref({})
const getParams = async () => {
    // const { data } = await funApi.tool_edit_phone_config(formData.id)
    // paramsData.value = { ...data }
}
defineExpose({ open });
</script>